// 定义路由处理函数类型
type RouteConfig = {
  path: string
  component: () => Promise<typeof import('*.vue')>
}

const routes: RouteConfig[] = [
  {
    path: '/login',
    component: () => import('@/views/Login/index.vue'),
    meta: { title: '登录' }
  },
  // 其他路由配置...
  {
    path: '/',
    component: () => import('@/views/Layout/index.vue'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: () => import('@/views/Home/index.vue'),
        meta: { title: '首页' }
      },
      {
        path: '/article',
        component: () => import('@/views/Article/index.vue'),
        meta: { title: '健康百科' }
      },
      {
        path: '/notify',
        component: () => import('@/views/Notify/index.vue'),
        meta: { title: '消息通知' }
      },
      {
        path: '/user',
        component: () => import('@/views/User/index.vue'),
        meta: { title: '个人中心' }
      }
    ]
  },
  {
    path: '/user/patients',
    component: () => import('@/views/User/patientPage.vue'),
    meta: { title: '家庭档案' }
  },
  {
    path: '/consult/fast',
    component: () => import('@/views/Consult/ConsultFast.vue'),
    meta: { title: '极速问诊' }
  },
  {
    path: '/consult/dep',
    component: () => import('@/views/Consult/ConsultDep.vue'),
    meta: { title: '选择科室' }
  },
  {
    path: '/consult/illness',
    component: () => import('@/views/Consult/ConsultIllness.vue'),
    meta: { title: '病情描述' }
  },
  {
    path: '/consult/pay',
    component: () => import('@/views/Consult/ConsultPay.vue'),
    meta: { title: '问诊支付' }
  },
  {
    path: '/room',
    component: () => import('@/views/Room/index.vue'),
    meta: { title: '问诊室' },
    // 支付失败，路由守卫函数(进入页面前执行)跳转到问诊信息
    beforeEnter(to: any) {
      // console.log(to.query.payResult)
      if (to.query.payResult == 'false') return 'user/consult'
    }
  },
  {
    path: '/user/consult',
    component: () => import('@/views/user/ConsultPage.vue'),
    meta: { title: '问诊记录' }
  },
  {
    path: '/user/consult/:id',
    component: () => import('@/views/user/ConsultDetail.vue'),
    meta: { title: '问诊详情' }
  },
  {
    path: '/order/pay',
    component: () => import('@/views/Order/OrderPay.vue'),
    meta: { title: '药品支付' }
  },
  {
    path: '/order/pay/result',
    component: () => import('@/views/Order/OrderPayResult.vue'),
    meta: { title: '药品支付结果' }
  }
]

export default routes
